import java.util.Hashtable;

/**
 * @author 赵希奥
 * @date 2022/4/20 11:41
 * @gitHub https://github.com/CKXGZXA
 * @gitee https://gitee.com/ckxgzxa
 * @description:
 */
public class MultiMediaFactory {
    private static MultiMediaFactory instance = new MultiMediaFactory();
    private static Hashtable ht;    // 使用Hashtable来存储享元对象, 充当享元池

    public MultiMediaFactory() {
        ht = new Hashtable();
        MultiMedia image = new Image();
        ht.put("image", image);
        MultiMedia video = new Video();
        ht.put("video", video);
        MultiMedia Animation = new Animation();
        ht.put("animation", Animation);
    }

    // 返回享元工厂的唯一实例
    public static MultiMediaFactory getInstance() {
        return instance;
    }

    public static MultiMedia getMultiMedia(String name) {
        return (MultiMedia) ht.get(name);
    }

}
